layui.use(['table', 'layer'], function () {
    var table = layui.table;
    var layer = layui.layer;
    var $ = layui.jquery;

    var GroupMember = {
        tableId: "groupMemberTable",    //表格id
        condition: {
            msisdn: ""
        }
    };

    GroupMember.initColumn = function () {
        return [[
            {type: 'numbers', align: "center", title: '序号'},
            {field: 'memberNum', align: "center", title: 'MSISDN'}
        ]];
    };

    table.render({
        elem: '#' + GroupMember.tableId,
        url: Feng.ctxPath + '/ecGroup/groupMembers?groupId=' + $("#ecGroupId").val() + '&accountId=' + $("#ecAccountId").val(),
        height: "full-98",
        cellMinWidth: 100,
        page: true,
        limits: [10,20,30,40,50],
        cols: GroupMember.initColumn()
    });

    /**
     * 为查询按钮添加点击事件
     */
    $(document).on('click',"#btnSearch",function(){
        search();
    });

    /**
     * 点击查询按钮
     */
    function search() {
        var queryData = {};
        queryData['msisdn'] = $("#msisdn").val();
        table.reload(GroupMember.tableId, {
            where: queryData
        });
    };

    /**
     * 为增/删按钮添加点击事件
     */
    $(document).on('click',"#btnAdd",function(){
        openAddOrDelete();
    });

    /**
     * 点击增/删按钮
     */
    function openAddOrDelete() {
        layer.open({
            type: 2,
            title: '添加/删除成员',
            area: ['750px', '475px'],
            skin: 'layui-layer-molv',
            content: Feng.ctxPath+'/ecGroup/toAddOrDeleteGroupMember/' + $("#ecGroupId").val() + '/' + $("#ecAccountId").val()
        });
    };

    /**
     * 为群组成员流量限额设置按钮添加点击事件
     */
    $(document).on('click',"#btnDelete",function(){
        onSetFlow();
    });

    /**
     * 群组成员流量限额设置
     *
     */
    function onSetFlow() {
        layer.open({
            type: 2,
            title: '群组成员流量限额设置',
            area: ['750px', '450px'],
            skin: 'layui-layer-molv',
            content: Feng.ctxPath+'/ecGroup/toSetGroupMemberFlow/' + $("#ecGroupId").val() + '/' + $("#ecAccountId").val()
        });
    };
});